package jp.oesf.rssreader;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class RssReaderSQLiteOpenHelper extends SQLiteOpenHelper {
	public static final String RSS_READER_DATABASE = "RSS_READER_DATABASE";
	public static final String CHANNEL_TABLE = "CHANNEL_TABLE";
	public static final String ITEM_TABLE = "ITEM_TABLE";

	public RssReaderSQLiteOpenHelper(Context context) {
		// RSS　DB　作成
		super(context, RSS_READER_DATABASE, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		// チャネルテーブル作成
		database.execSQL("CREATE TABLE " + CHANNEL_TABLE
				+ "(_id INTEGER PRIMARY KEY AUTOINCREMENT"
				+ ",channel TEXT not null" 
				+ ",channelUrl TEXT" + ");");
		//　記事テーブル作成
		database.execSQL("CREATE TABLE " + ITEM_TABLE
				+ "(_id INTEGER PRIMARY KEY AUTOINCREMENT"
				+ ",channelId INTEGER not null" 
				+ ",title TEXT" 
				+ ",link TEXT" 
				+ ",description TEXT" 
				+ ",pubDate TEXT" 
				+ ",category TEXT" 
				+ ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
	}
}
